<html>
    <head><title>add student</title>
    </head>
    <body>
        <?php 
                require_once('/Users/CTR/desktop/phpweb1/conn.php');
                $name=$_POST[name];
                $sex=$_POST[sex];
                $classnum=$_POST[classnum];
                $grade=$_POST[grade];
                $major=$_POST[major];
                
                $query="INSERT INTO mytable(name,sex,classnum,grade,major)VALUES('$name','$sex','$classnum','$grade','$major')";
                  
                $stmt=mysqli_prepare($conn,$query);
                
                mysqli_execute($stmt);
                
                $affected_rows= mysqli_stmt_affected_rows($stmt);
                
                if($affected_rows==1){
                    
                    echo '数据已添加';
                    
                    mysqli_stmt_close($stmt);
                    
                    mysqli_close($conn);
                    
                }else{
                    
                    echo '提交失败<br />';
                    echo mysqli_error();
                    
                    mysqli_stmt_close($stmt);
                    
                    mysqli_close($conn);
                }
            ?>

        <?php include ('links.txt');?> 
　　</body> 
</html>     
    